package company.meicai;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

//1,2,3#4,5,6#7,8,9
public class Mei {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] levels = s.split("#");
        String[] nums = levels[0].split(",");
        int[][] dict = new int[levels.length][nums.length];
        for (int i = 0; i < levels.length; i++) {
            String level = levels[i];
            String[] tmpNum = level.split(",");
            for (int j = 0; j < nums.length; j++) {
                dict[i][j] = Integer.parseInt(tmpNum[j]);
            }
        }
        StringBuilder route = getRoute(dict);
        System.out.println(route.substring(0,route.length()-1));
    }

    public static StringBuilder getRoute(int[][] matrix) {
        StringBuilder ans = new StringBuilder();
        if (matrix == null || matrix.length == 0) {
            return ans;
        }
        int up = 0;
        int down = matrix.length - 1; //行高
        int left = 0;
        int right = matrix[0].length - 1; // 列高
        while (true) {
            //向右
            for (int i = left; i <= right; i++) {
                ans.append(matrix[up][i]).append(",");
            }
            if (++up > down) {
                break;
            }
            //向下
            for (int i = up; i <= down; i++) {
                ans.append(matrix[i][right]).append(",");
            }
            if (--right < left) {
                break;
            }
            //向左
            for (int i = right; i >= left; i--) {
                ans.append(matrix[down][i]).append(",");
            }
            if (--down < up) {
                break;
            }
            //向上
            for (int i = down; i >= up; i--) {
                ans.append(matrix[i][left]).append(",");
            }
            if (++left > right) {
                break;
            }
        }
        return ans;
    }
}
